﻿Public Partial Class DettaglioNews1
    Inherits System.Web.UI.Page
    Public docsPath As String = ConfigurationManager.AppSettings("docsPath").Replace("~", String.Empty)
    Public IDNews As Guid = Nothing
    Public pageTitle As String = ConfigurationManager.AppSettings("sitename")
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            If Not String.IsNullOrEmpty(Request.QueryString("id")) Then
                IDNews = New Guid(Request.QueryString("id"))
                Page.Title = pageTitle & " - Dettaglio News"
                Dim news As News = DAL.Context.News.Where(Function(n) n.ID = IDNews).Single
                If news IsNot Nothing Then
                    With news
                        lblDataPubblicazione.Text = "[" & .DataPubblicazione.ToShortDateString & "]"
                        lblTitolo.Text = .Titolo
                        ltTesto.Text = .Testo
                        rpDocumenti.DataSource = .NewsAllegati.ToList
                        rpDocumenti.DataBind()
                    End With
                End If
            Else
                Response.Redirect(Page.ResolveUrl("~/GUI/Error.aspx"))
            End If
        End If
    End Sub
End Class